******************************************************************************************
***CLASSROOMS OR CRACKDOWNS? HOW VIOLENCE AFFECTS SECURITY POLICY PREFERENCES IN MEXICO***
***Authors: Sarah Berens, Ana I. López García, Barry Maydom*******************************
******************************************************************************************

*PLOTS
*Figure 1: Average marginal effects of experimental attributes on support for increased state security presence
*Figure 2: Conditional marginal effects of experimental attributes by crime victimization experiences
*Figure 3: Conditional marginal effects of experimental attributes by feelings of insecurity
*Figure 4: Conditional marginal effects of experimental attributes by exposure to state abuse 


use "Data ready E5.dta", clear 

*Plot style
grstyle init 
grstyle set plain, nogrid
grstyle set color mono
grstyle set legend, nobox 
grstyle color background white 
graph set window fontface "Arial"

*********************
*1. FIGURE 1: Average marginal effects of experimental attributes on support for increased state security presence
grstyle set graphsize 7.5 8.5 
reg E5_crime_measures i.E5_vign2 i.E5_vign1 
margins, dydx(*) post 
est store figure1
coefplot (figure1, level(95 90)  ciopts(lcolor(black)) msymbol (O) mlcolor(black) mfcolor(white)), ///
	xline(0, lcolor(black) lwidth(medium) lpat(shortdash)) baselevels  ///
	drop(_cons) byopts(xrescale) norecycle     ///
	xtitle("{bf:Linear Reg. Coefficient}", size(small) margin(l+0 r+0 b+0 t+2)) ///
	headings(0.E5_vign2 = "{bf: Complementary policies}" ///
	0.E5_vign1 = "{bf:Territorial scope}") ///
	msize(small) msymbol(d) mlabposition(center) /// 
	title("	DV: Support for increased state security presence ", size(medsmall) margin(l+0 r+0 b+3 t+0)) /// 
	xlab(-0.6 (0.2) 0.6, labsize(small)) /// 
	coeflabels(, labsize(small)) scale(0.95)	
graph save "Figure1_9095.gph", replace 
	graph export "Figure1_9095.eps", as(eps) replace 
	graph export "Figure1_9095.tif", as(tif) replace 
	graph export "Figure1_9095.png", as(png) replace 
		

********************************************************************
*2. FIGURE 2: Conditional marginal effects of experimental attributes by crime victimization experiences

reg E5_crime_measures i.E5_vign1##i.E5_vign2##i.violence_victim
est store crime_victim

est restore crime_victim
margins 	r.E5_vign2, at(violence_victim=0) level(95) post
est store 	pr_0

est restore crime_victim
margins 	r.E5_vign2, at(violence_victim=1) level(95) post
est store 	pr_1

est restore crime_victim
margins 	r.E5_vign2, at(violence_victim=2) level(95) post
est store 	pr_2


*FIGURE 2 with 90 and 95 CIs all in one

grstyle set graphsize 7.5 8.5 
grstyle set legend 6
grstyle numstyle legend_rows 1

coefplot (pr_0, level(95 90) label("Nonvictim") msymbol(o)) (pr_1, level(95 90) label("Violent Crime") msymbol(X)) (pr_2, level(95 90) label("Nonviolent crime") msymbol(t)), ///
	xline(0, lcolor(black) lwidth(medium) lpat(shortdash))  /// 
	xtitle("{bf:Linear Reg. Coefficient}", size(small) margin(l+0 r+0 b+0 t+2)) ///
	legend(title("")  margin(small) size(small)) ///
	recast(scatter)  ///
	ylabel( 1 "youth education" 2 "youth employment" 3 "in-prison rehabilitation" 4 "harsher sentences" 5 "aggressive policing", labsize(small)) ///
	title("	DV: Support for increased state security presence ", size(medsmall) margin(l+0 r+0 b+4 t+0)) ///
	xlab(-1(0.5)1, labsize(small)) /// 
	coeflabels(, labsize(small)) scale(0.95)
	
graph save "Figure2_9095.gph", replace 
	graph export "Figure2_9095.eps", as(eps) replace 
	graph export "Figure2_9095.tif", as(tif) replace 
	graph export "Figure2_9095.png", as(png) replace 
	

********************************************************************************************	
*FIGURE 3: Conditional marginal effects of experimental attributes by feelings of insecurity

*FEAR
reg E5_crime_measures i.E5_vign1##i.E5_vign2##i.unsafe_state
est store unsafe_state

est restore unsafe_state
margins 	r.E5_vign2, at(unsafe_state=0) level(95) post
est store 	pr_3

est restore unsafe_state
margins 	r.E5_vign2, at(unsafe_state=1) level(95) post
est store 	pr_4

*VIGILANTES
reg E5_crime_measures i.E5_vign1##i.E5_vign2##i.vigilantes_neigh
est store vigilantes_neigh

est restore vigilantes_neigh
margins 	r.E5_vign2, at(vigilantes_neigh=0) level(95) post
est store 	pr_5

est restore vigilantes_neigh
margins 	r.E5_vign2, at(vigilantes_neigh=1) level(95) post
est store 	pr_6


*FIGURE 3a - FEAR	with 90 and 95 CIs all in one
coefplot (pr_3, level(95 90) label(Safe) msymbol(o)) (pr_4, level(95 90) label(Unsafe) msymbol(X)), ///
	xline(0, lcolor(black) lwidth(medium) lpat(shortdash))  /// 
	xtitle("{bf:Linear Reg. Coefficient}", size(small) margin(l+0 r+0 b+0 t+2)) ///
	legend(title("")  margin(small) size(small)) ///
	recast(scatter)  ///
	ylabel( 1 "youth education" 2 "youth employment" 3 "in-prison rehabilitation" 4 "harsher sentences" 5 "aggressive policing", labsize(small)) ///
	title("Perceived safety in the state of residence", margin(l+0 r+0 b+2 t+0) size(medsmall)) ///
	xlab(-0.8(0.4)0.8, labsize(small)) 
graph save "Figure3a_9095.gph", replace 

*FIGURE 3b - VIGILANTISM with 90 and 95 CIs all in one
coefplot (pr_5, level(95 90) label(No groups) msymbol(s)) (pr_6, level(95 90) label(Groups) msymbol(t)), ///
	xline(0, lcolor(black) lwidth(medium) lpat(shortdash))  /// 
	xtitle("{bf:Linear Reg. Coefficient}", size(small) margin(l+0 r+0 b+0 t+2)) ///
	legend(title("")  margin(small) size(small)) ///
	recast(scatter)  ///
	ylabel( 1 "youth education" 2 "youth employment" 3 "in-prison rehabilitation" 4 "harsher sentences" 5 "aggressive policing", labsize(small)) ///
	title("Security watchgroups in neighborhood", margin(l+0 r+0 b+2 t+0) size(medsmall)) ///
	xlab(-0.8(0.4)0.8, labsize(small)) 
graph save "Figure3b_9095.gph", replace 
	
* Figure 3 with 90 and 95 CIs all in one	
grstyle set graphsize 7 14 
graph combine "Figure3a_9095.gph" "Figure3b_9095.gph", cols(2) /// 
	title("			DV: Support for increased state security presence", size(medsmall) margin(l+0 r+0 b+3 t+0)) scale(1.1)
graph save "Figure3_9095.gph", replace 
	graph export "Figure3_9095.eps", as(eps) replace 
	graph export "Figure3_9095.tif", as(tif) replace 
	graph export "Figure3_9095.png", as(png) replace 
	
**********************************************************************	

*FIGURE 4: Conditional marginal effects of experimental attributes by exposure to state abuse 

*STATE VIOLENCE 
reg E5_crime_measures i.E5_vign1##i.E5_vign2##i.police_abuse
est store police_abuse

est restore police_abuse
margins 	r.E5_vign2, at(police_abuse=0) level(95) post
est store 	pr_7

est restore police_abuse
margins 	r.E5_vign2, at(police_abuse=1) level(95) post
est store 	pr_8


*STATE VIOLENCE + CRIME
reg E5_crime_measures i.E5_vign1##i.E5_vign2##i.crime_state
est store crime_state

est restore crime_state
margins 	r.E5_vign2, at(crime_state=0) level(95) post
est store 	pr_9

est restore crime_state
margins 	r.E5_vign2, at(crime_state=1) level(95) post
est store 	pr_10

est restore crime_state
margins 	r.E5_vign2, at(crime_state=2) level(95) post
est store 	pr_11

est restore crime_state
margins 	r.E5_vign2, at(crime_state=3) level(95) post
est store 	pr_12


grstyle set graphsize 7.5 8.5 

coefplot (pr_7, level(95 90) label(Nonvictim) msymbol(o)) (pr_8, level(95 90) label(State violence) msymbol(t)), ///
	xline(0, lcolor(black) lwidth(medium) lpat(shortdash))  /// 
	xtitle("{bf:Linear Reg. Coefficient}", size(small) margin(l+0 r+0 b+0 t+2)) ///
	legend(title("")  margin(small) size(small)) ///
	recast(scatter)  ///
	ylabel( 1 "youth education" 2 "youth employment" 3 "in-prison rehabilitation" 4 "harsher sentences" 5 "aggressive policing", labsize(small)) ///
	title("State abuse",  margin(l+0 r+0 b+2 t+0) size(medsmall)) ///
	xlab(-0.8(0.4)0.8, labsize(small)) 
graph save "Figure4a_9095.gph", replace 

	
*FIGURE 4b - STATE ABUSE + crime
coefplot (pr_9, level(95 90) label(None) msymbol(o)) (pr_10, level(95 90) label(State abuse only) msymbol(t)) (pr_11, level(95 90) label(Both) msymbol(s)) (pr_12, level(95 90) label(Crime only) msymbol(X)), ///
	xline(0, lcolor(black) lwidth(medium) lpat(shortdash))  /// 
	xtitle("{bf:Linear Reg. Coefficient}", size(small) margin(l+0 r+0 b+0 t+2)) ///
	legend(title("")  margin(small) size(small)) ///
	recast(scatter)  ///
	ylabel( 1 "youth education" 2 "youth employment" 3 "in-prison rehabilitation" 4 "harsher sentences" 5 "aggressive policing", labsize(small)) ///
	title("Double victimization", margin(l+0 r+0 b+2 t+0) size(medsmall)) ///
	xlab(-0.8(0.4)0.8, labsize(small)) 
graph save "Figure4b_9095.gph", replace 

*FIGURE 3a - CRIME BY NONSTATE AND STATE ACTORS	with 90 and 95 CIs all in one

grstyle set graphsize 7 14
graph combine "Figure4a_9095.gph" "Figure4b_9095.gph", cols(2) /// 
	title("			DV: Support for increased state security presence ", size(medsmall) margin(l+0 r+0 b+3 t+0)) scale(1.1)
graph save "Figure4_9095.gph", replace 
	graph export "Figure4_9095.eps", as(eps) replace 
	graph export "Figure4_9095.tif", as(tif) replace 
	graph export "Figure4_9095.png", as(png) replace 

	
